package com.w.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.w.domain.Gly;
import com.w.domain.User;
import com.w.domain.WenJian;
import com.w.mapper.UserMapper;
import com.w.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public PageInfo getAllInfo(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<User> users = userMapper.selectAllInfos();
        PageInfo<User> pageInfo = new PageInfo<>(users);
        return pageInfo;
    }

    @Override
    public PageInfo<WenJian> getAllWenjian(String name, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        ArrayList<WenJian> list = userMapper.selectAllWenjian(name);
        PageInfo<WenJian> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public int deleteOne(Integer wid) {
        return userMapper.deleteOne(wid);
    }

    @Override
    public WenJian getOneWenjian(Integer wid) {
        return userMapper.getOneWenjian(wid);
    }

    @Override
    public void insertInfo(User user) {
        userMapper.insertSelectiveOneInfos(user);
    }

    @Override
    public Long selectFwl() {
        return userMapper.selectFwl();
    }

    @Override
    public void updataFwl(Long sums) {
        userMapper.updataFwl(sums);
    }

    @Override
    public int deleteInfo(String ip) {
        return userMapper.deleteInfo(ip);
    }

    @Override
    public Gly glyLogin(Gly gly) {
        return userMapper.getCly(gly);
    }

    @Override
    public String getHappyInfo(int id) {
        return userMapper.getHappyInfo(id);
    }

    @Override
    public int insertWenjian(WenJian wenJian) {
        return userMapper.insertWenjian(wenJian);
    }

}


